#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "Servo.h"
#include "key.h"
#include "PWM.h"

uint8_t Keynum=0;//按键键码
float Angle;//角度变量
int main(void){
	OLED_Init();

	PWM_Init();
//	//PWM_set(500);//此时时间为0.5ms，处于不动的状态
	//PWM_set(2500);//此时时间为2.5ms，转180°
//	PWM_set(1500);//此时时间为1.5ms，转90°
	Key_Init();
	Servo_Init();
	OLED_ShowString(1,1,"Angle:");
	while(1){
		Keynum=Key_GetNum();
		if(Keynum==1){
			Angle+=30;
			if(Angle>180){
				Angle=0;
			}
		}
		Servo_Setangle(Angle);
		OLED_ShowNum(1,7,Angle,3);
	}
}
